package com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.entity.req.SmsWnsCampusGuideReq;
import com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.service.SmsWnsCampusGuideService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 校园指南表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-01-28
 */
@RestController
@RequestMapping("/welcomeNewStudent/campusGuide")
@SecretBody
public class SmsWnsCampusGuideController {

    @Resource
    private SmsWnsCampusGuideService smsWnsCampusGuideService;
    @Resource
    private JwtTokenUtil jwtTokenUtil;

    @ApiOperation("添加校园指南")
    @PostMapping("/add")
    public ResponseResult addCampusGuide(HttpServletRequest request, @RequestBody SmsWnsCampusGuideReq addReq){
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return smsWnsCampusGuideService.addCampusGuide(userId,addReq);
    }

    @ApiOperation("删除校园指南")
    @PostMapping("/deleted")
    public ResponseResult deletedCampusGuide(@RequestBody SmsWnsCampusGuideReq deletedReq){
        return smsWnsCampusGuideService.deletedCampusGuide(deletedReq);
    }


    @ApiOperation("修改校园指南")
    @PostMapping("/update")
    public ResponseResult updateCampusGuide(@RequestBody SmsWnsCampusGuideReq updateReq){
        return smsWnsCampusGuideService.updateCampusGuide(updateReq);
    }

    @ApiOperation("获取校园指南详情")
    @GetMapping("/id")
    public ResponseResult getCampusGuideDetail(@RequestParam(value = "id")String id){
        return smsWnsCampusGuideService.getCampusGuideDetail(id);
    }

    @ApiOperation("获取校园指南列表")
    @GetMapping("/list")
    public ResponseResult getCampusGuideList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                             @RequestParam(value = "createDate", required = false) String createDate,
                                             @RequestParam(value = "guideTheme", required = false) String guideTheme,
                                             @RequestParam(value = "publisher", required = false) String publisher,
                                             @RequestParam(value = "isUse", required = false) Integer isUse){
        return smsWnsCampusGuideService.getCampusGuideList(createDate,guideTheme,publisher,isUse,pageNum,pageSize);
    }


}

